﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RegisterBind.aspx.cs" Inherits="NJL.WebUsersRegisterBind" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>完善注册信息</title>
    <link rel="stylesheet" type="text/css" href="/Styles/base1.css" />
    <link href="/Styles/manage.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/md5.js" type="text/javascript" language="javascript"></script>
    <script src="/Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        var regEmail = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;  //验证电子邮件正则表达式
        var regUserName = /^(\w|[\u4E00-\u9FA5])+$/;   //验证用户昵称只能输入数字，26个字母，或汉字
        var txtEmail = "";          //电子邮件
        var txtPwdEmail = "";        //密码

        function fCheckCodeEmail() {
            txtEmail = document.getElementById("<%=txtEmail.ClientID %>").value;                   //电子邮件
            txtPwdEmail = document.getElementById("<%=txtPwdEmail.ClientID %>").value;             //密码
            txtEmail = $.trim(txtEmail);
            txtPwdEmail = $.trim(txtPwdEmail);
            if (txtEmail == "") {
                document.getElementById("EmailError").innerHTML = "请输入电子邮件地址";
                return false;
            }
            if (regEmail.exec(txtEmail) == null) {
                document.getElementById("EmailError").innerHTML = "请输入正确的电子邮件地址";
                return false;
            }
            if (document.getElementById("hidEmail").value == "1") {
                document.getElementById("EmailError").innerHTML = "电子邮件地址已经被注册";
                return false;
            }
            if (txtPwdEmail == "") {
                document.getElementById("PwdEmailError").innerHTML = "请输入密码";
                return false;
            }
            if (txtPwdEmail.length < 6 | txtPwdEmail.length > 20) {
                document.getElementById("PwdEmailError").innerHTML = "请输入6-20位密码信息";
                return false;
            }
            document.getElementById("<%=hidPasswordCellEmail.ClientID %>").value = md5(txtPwdEmail);
        }

        //电子邮件
        function checeEmail() {
            txtEmail = document.getElementById("<%=txtEmail.ClientID %>").value;
            txtEmail = $.trim(txtEmail);
            if (txtEmail == "") {
                document.getElementById("EmailError").innerHTML = "请输入电子邮件地址";
            }
            else if (regEmail.exec(txtEmail) == null) {
                document.getElementById("EmailError").innerHTML = "请输入正确电子邮件地址";
            }
            else {
                $.ajax({
                    type: 'get',
                    url: 'Handle/Handler.ashx',
                    data: 'Email=' + txtEmail + '&Random=' + Math.random(),
                    dataType: 'text',
                    success: function (msg) {
                        if (msg == "NOEmail") {
                            document.getElementById("EmailError").innerHTML = "电子邮件地址已经被注册";
                            document.getElementById("hidEmail").value = "1";
                        }
                        else {
                            document.getElementById("EmailError").innerHTML = "";
                            document.getElementById("hidEmail").value = "0";
                        }
                    },
                    error: function () {

                    }
                })
            }
        }

        //密码
        function checkPwdEmail() {
            txtPwdEmail = document.getElementById("<%=txtPwdEmail.ClientID %>").value;
            txtPwdEmail = $.trim(txtPwdEmail);
            if (txtPwdEmail == "") {
                document.getElementById("PwdEmailError").innerHTML = "请输入密码";
            }
            else {
                if (txtPwdEmail.length < 6 | txtPwdEmail.length > 20) {
                    document.getElementById("PwdEmailError").innerHTML = "请输入6-20位密码信息";
                }
                else {
                    document.getElementById("PwdEmailError").innerHTML = "";
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <input type="hidden" id="hidPasswordCellEmail" runat="server" />
    <div class="cleanFlex">
        <div class="m_top_10">
        </div>
        <!--注册-->
        <div class="reg cont  cleanFlex" style="height:350px; border:none;">
            <h1>
                完善注册信息<br /><span>(请输入有效的电子邮件和密码，可以通过该帐号登录本网站)</span></h1>
            <div class="main">
                <div class="item">
                    <p class="info"><label>
                        电子邮件</label><span id="eml">请填写有效邮箱。</span></p>
                    <asp:TextBox ID="txtEmail" runat="server" MaxLength="30" onblur="checeEmail()" Style="width: 260px;"></asp:TextBox>
                    <span class="fonterror" runat="server" id="EmailError"></span>
                </div>
                <div class="item">
                    <p class="info"><label>
                        登录密码</label><span>6-20位，可以使用英文（区分大小写），数字和符号。</span></p>
                    <asp:TextBox ID="txtPwdEmail" runat="server" TextMode="Password" MaxLength="20" onblur="checkPwdEmail()"
                        Style="width: 160px;"></asp:TextBox>
                    <span class="fonterror" id="PwdEmailError"></span>
                </div>
                
                <asp:Button ID="btnSubmitEmail" runat="server" Text="" OnClick="btnSubmitEmail_Click"
                    CssClass="nextbtn" OnClientClick="return fCheckCodeEmail()" />
            </div>
            <!--协议-->
        </div>
    </div>
    <input id="hidEmail" type="hidden" />
    <input id="hidcheck" type="hidden" />
    </form>
</body>
</html>
